package org.deltaset.meta.internal;

import java.util.List;
import org.deltaset.meta.MetaAction;
import org.deltaset.meta.MetaActionExecutor;
import org.deltaset.meta.MetaField;

/**
 *
 * @author dmakariev
 */
class MetaActionExecutorImpl implements MetaActionExecutor {

    private final MetaAction current;
    private final Object parameterValue;

    MetaActionExecutorImpl(final MetaAction current) {
        this.current = current;
        this.parameterValue = current.getNewParameterInstance();
    }

    @Override
    public MetaAction getMetaAction() {
        return current;
    }

    @Override
    public Object getParameterValue() {
        return parameterValue;
    }

    @Override
    public Object[] getParameters() {
        if (!current.getHasParameter()) {
            return new Object[0];
        }
        final Object[] parameters = current.prepareParameters(parameterValue);
        return parameters;
    }

    @Override
    public List<MetaField> getMetaFields() {
        return current.getParameterMetaFields();
    }
}
